package factoryMode.factory.factoryMethod.order;

import factoryMode.factory.factoryMethod.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author： pang-yun
 * @date： 2021-10-21 19:47
 * 功能目的 ：用于
 */

public abstract class PizzaOrder {

    // 定义一个 抽象方法   createPizza  让各个工厂子类 自己实现
    abstract Pizza createPizza(String orderType);

    public PizzaOrder() {
        Pizza pizza = null;
        String orderType;
        do {
            orderType = getType();
            pizza = createPizza(orderType);
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();

        } while (true);
    }


    //从控制台 获取想订购pizza 的种类
    private String getType() {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("输入pizza种类:");
            String s = reader.readLine();
            return s;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
